package com.taorenqi.data.converter;

import com.google.gson.Gson;
import com.taorenqi.data.common.BaseResponse;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by eric on 2017/9/21.
 */

public class HotResponseConverter extends BaseResponseConverter<BaseResponse>{

    @Override
    public BaseResponse parserJson(String json) {
        BaseResponse bean = new BaseResponse();
        try {
            JSONObject jsonRoot = new JSONObject(json);
            String code = jsonRoot.getString("code");
            if ("1".equals(code)) {
                JSONObject jsonPkg = jsonRoot.getJSONObject("dataObject");

                JSONArray JAcontents = jsonPkg.getJSONArray("datalist");
                List<String> contents = new ArrayList<>();
                for (int i = 0; i < JAcontents.length(); i++) {
                    contents.add(JAcontents.getString(i));
                }
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return bean;
    }
}
